//
//  ST_EditMyInfoGuidanceHeader.swift
//  btvideo
//
//  Created by mac on 2020/2/29.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit

class ST_EditMyInfoGuidanceHeader: UIView {

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = Color.init(hexString: "#ED3E58")
        
        self.addSubview(left_image_view)
        left_image_view.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(35)
        }
        
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(left_image_view.snp.right).offset(10)
            make.top.equalTo(left_image_view)
        }
        
        self.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.left.equalTo(left_image_view.snp.right).offset(10)
            make.top.equalTo(titleLabel.snp.bottom).offset(9)
        }
        
        self.addSubview(edit_btn)
        edit_btn.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.width.equalTo(60)
            make.height.equalTo(25)
            make.centerY.equalToSuperview()
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    MARK: - Properties
    fileprivate lazy var left_image_view:UIImageView = {
       let control = UIImageView()
        control.image = ST_ImageUtils.imageName("个人中心_icon_编辑提示")
        return control
    }()
    
    fileprivate lazy var titleLabel:UILabel = {
        let control = UILabel()
        let attrString = NSMutableAttributedString(string: "你的自我介绍还没有填写！")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 1, green: 1, blue: 1, alpha: 1)]
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        control.attributedText = attrString
        return control
    }()
    
    fileprivate lazy var content_label:UILabel = {
        let control = UILabel()
        let attrString = NSMutableAttributedString(string: "好的自我介绍能够让别人更好的认识自己")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular),.foregroundColor: UIColor(red: 1, green: 1, blue: 1, alpha: 1)]
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        control.attributedText = attrString
        return control
    }()
    

    fileprivate lazy var edit_btn:UIButton = {
            
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.backgroundColor = Color.white
        control.cornerRadius = 26/2.0
        let attrString = NSMutableAttributedString(string: "去填写")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 0.93, green: 0.24, blue: 0.35, alpha: 1)]
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        control.setAttributedTitle(attrString, for: UIControl.State.normal)
        control.addTarget(self, action: #selector(editHandle), for: UIControl.Event.touchUpInside)
        
        return control
    }()

    var edit_closure:(()->())?
}

//MARK: - Event
extension ST_EditMyInfoGuidanceHeader{
    
    @objc func editHandle(){
        
        edit_closure?()
        
    }
}

